package com.example.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRedissonConfig {
    /**
     * 所有对Redisson的使用都是通过redissonClient对象
     * https://github.com/redisson/redisson 官方文档地址
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
// 1. Create config object
        //创建配置
        Config config = new Config();
        //根据Config对象创建出RedissonClient对象
        config.useSingleServer().setAddress("redis://192.168.2.2:6379").setPassword("123456");
        return Redisson.create(config);

    }
}
